﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utilities.Net;
using System.Net;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ProjetS5
{
    public class ServerInfo
    {
        public ServerInfo()
        {
            address = "Adresse IP";
            name = "Nom de partie";
            difficulty = "Difficulte";
            nbPlayers = "Nombre de Joueurs";
        }
        public ServerInfo(ServerDiscoveryEventArgs serverDiscovery)
        {
            address = serverDiscovery.IpEndPoint.Address.ToString();
            int diff = Int32.Parse(serverDiscovery.Data.Substring(0, 1));
            difficulty = ((Difficulty)diff).ToString();
            nbPlayers = serverDiscovery.Data.Substring(2, 1);
            name = serverDiscovery.Data.Substring(4);
        }

        public static SpriteFont font;
        public String difficulty;
        public String address;
        public String name;
        public String nbPlayers;

        public void Draw(SpriteBatch spriteBatch, Vector2 relativePosition)
        {
            // IPAddress    Name    Difficulty  NbPlayers
            spriteBatch.DrawString(font, address, relativePosition, Color.White);
            spriteBatch.DrawString(font, name, Vector2.Add(relativePosition, new Vector2(200, 0)), Color.White);
            spriteBatch.DrawString(font, difficulty, Vector2.Add(relativePosition, new Vector2(400, 0)), Color.White);
            spriteBatch.DrawString(font, nbPlayers, Vector2.Add(relativePosition, new Vector2(600, 0)), Color.White);
        }
    }
}
